package ${webPackageName}.utils;

import javax.servlet.http.HttpServletRequest;

import ${servicePackageName}.dto.sys.UserDto;

/**
 * 
 * @author lizihao
 *
 */
public class RequestHolder {

	private static final ThreadLocal<UserDto> USERHOLDER = new ThreadLocal<UserDto>();

    private static final ThreadLocal<HttpServletRequest> REQUESTHOLDER = new ThreadLocal<HttpServletRequest>();

    public static void add(UserDto sysUser) {
    	USERHOLDER.set(sysUser);
    }

    public static void add(HttpServletRequest request) {
    	REQUESTHOLDER.set(request);
    }

    public static UserDto getCurrentUser() {
        return USERHOLDER.get();
    }

    public static HttpServletRequest getCurrentRequest() {
        return REQUESTHOLDER.get();
    }

    public static void remove() {
    	USERHOLDER.remove();
        REQUESTHOLDER.remove();
    }
}
